# 定义公共的断言方法
import json

from config import BASE_DIR


def utils_assert(resp, status_code, code, msg):
    assert resp.status_code == status_code
    assert resp.json().get("code") == code
    assert resp.json().get("msg") == msg
    # try:
    #     assert resp.status_code == status_code
    #     assert resp.json().get("code") == code
    #     assert resp.json().get("msg") == msg
    # except Exception as e:
    #     return e


# 定义公共的读取数据的方法
def read_json_data(filename):
    # 1.打开json文件，解析成列表/字典
    file_path = BASE_DIR + "/data/" +filename
    with open(file_path,encoding="utf8") as f:
        json_data = json.load(f)
    # 2.遍历列表，将列表中的所有字典的值取出来
    test_case_list = []
    for i in json_data:
        value = i.values()
    # 3.转换为元组格式，添加到新列表
        test_case_list.append(tuple(value))
    print(test_case_list)
    return  test_case_list

# def read_coursejson_data(filename):
#     # 1.打开json文件，解析成列表/字典
#     file_path = BASE_DIR + "/data/addcourse_data" + filename
#     with open(file_path, encoding="utf8") as f:
#         json_data = json.load(f)
#     # 2.遍历列表，将列表中的所有字典的值取出来
#     test_addcourse_list = []
#     for i in json_data:
#         value = i.values()
#         # 3.转换为元组格式，添加到新列表
#         test_addcourse_list.append(tuple(value))
#     print(test_addcourse_list)
#     return test_addcourse_list

if __name__ == "__main__":
    read_json_data("login_data.json")


# def read_json(myjsonfile):
#     file_path = BASE_DIR + "/data/" + myjsonfile
#     with open(file_path, encoding="utf8") as f:
#         json_data = json.load(f)
#         test_new_list = []
#         for i in json_data:
#             value = i.values()
#             test_new_list.append(tuple(value))
#         print(test_new_list)
#         return test_new_list
#
#
# if __name__ == "__main__":
#     read_json("login_data.json")
